from selenium.webdriver.common.by import By

from BasePage.basepage import BasePage


class PageNowPay(BasePage):
    def __init__(self, driver):
        super().__init__(driver)
        self.driver = driver
         #     选择商品
        self.card_loc = (By.ID, "com.tpshop.malls:id/product_pic_img")
        # 立即购买、
        self.buy_now = (By.ID, "com.tpshop.malls:id/promptly_buy_tv")
        # 确认购买
        self.submit_order = (By.ID, "com.tpshop.malls:id/confirm_tv")
        # 提交订单
        self.sub = (By.ID, "com.tpshop.malls:id/submit_tv")
        # 立即支付
        self.pay_now=(By.ID, "com.tpshop.malls:id/pay_btn")
        # 输入密码
        self.password = (By.ID, "com.tpshop.malls:id/pwd_et")
        # 确认支付
        self.confirm_pay_btn = (By.ID, "com.tpshop.malls:id/sure_tv")
        self.sure_order_suc = (By.ID, "com.tpshop.malls:id/title_tv")

    def pay_now_goods(self,password):
        self.click_element(self.card_loc)
        self.click_element(self.buy_now)
        self.click_element(self.submit_order)
        self.click_element(self.sub)
        self.click_element(self.pay_now)
        self.base_clear_input(self.password,password)
        self.click_element(self.confirm_pay_btn)

    def pay_now_sucuse(self):
        result=self.get_element(self.sure_order_suc).text
        return result